<?php
$oPublicJobs = JobHandler::getPublicJobs();
$oUsers = UserHandler::getUsers();
loadBox('issue-add');
?>

<script language="JavaScript">
	var sJobNames = new Array();
	var iReceivers = new Array();
	var sUserNames = new Array();
<?php
foreach ($oUsers as $oThisUser) {
	?>
	sUserNames[<?php print $oThisUser->iID ?>] = new String('<?php print $oThisUser->sUser ?>');
	<?php
}
foreach ($oPublicJobs as $oThisJob) {
	?>
	sJobNames[<?php print $oThisJob->iID ?>] = new String('<?php print $oThisJob->sName ?>');
	iReceivers[<?php print $oThisJob->iID ?>] = new Array();
	var i = 0;
	<?php
	$iChangers = JobHandler::getUsersWithAccess('mission', 'write', $oThisJob->iID);
	foreach ($iChangers as $iThisChanger) {
		?>
		iReceivers[<?php print $oThisJob->iID ?>][i++] = <?php print $iThisChanger ?>;
		<?php
	}
}
?>
</script>

<table class="boxborder" cellspacing="0">
	<tr>
		<td class="boxhandle" colspan="3"><?php print msg('Project center') ?></td>
	</tr>
	<tr>
		<td class="listtop"><?php print msg('Project') ?></td>
		<td class="listtop center"><?php print msg('Owner') ?></td>
		<td class="listtop center"><?php print msg('Actions') ?></td>
	</tr>
<?php
foreach ($oPublicJobs as $oThisJob) {
	?>
	<tr>
		<td class="listentity nowrap">
	<?php
	if (JobHandler::canDo('job', 'read', $oThisJob->iID)) {
		print '<a href="index.php?sView=job-view&iJobID='.$oThisJob->iID.'">'.$oThisJob->sName.'</a>';
	}
	else {
		print $oThisJob->sName;
	}
	?>
		</td>
		<td class="listentity center nowrap">
	<?php
	if ($oThisJob->iOwner) {
		print '<a href="index.php?sView=user-view&iUser='.$oThisJob->iOwner.'">'.$oUsers[$oThisJob->iOwner]->sUser.'</a>';
	}
	else {
		print '[ <span class="error">'.msg('None').'</span> ]';
	}
	?>
		</td>
		<td class="listentity center">
			<input type="button" value="<?php print msg('Send issue') ?>" onClick="issue_add(<?php print $oThisJob->iID ?>);">
		</td>
	</tr>
	<?php
	
	if ($oThisJob->sDescription) {
		?>
		<tr>
			<td class="subentity small" colspan="3">
				<?php print nl2br(wordwrap($oThisJob->sDescription, 90)) ?>
			</td>
		</tr>
		<?php
	}
}
?>
</table>
